package View;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;

public class PatientPanel extends JPanel
{
	private JTextField timeText;
	private JTextField dateText;
	private String myUserID;
 
	public PatientPanel()
	{
//		myUserID = userID;
		setLayout(new BorderLayout());
		Color myColor = new Color(150, 190, 100);
		setPreferredSize(new Dimension(700, 500));
  
		//north panel
		JPanel panelNorth = new JPanel();
		panelNorth.setBackground(myColor);
		JLabel welcome = new JLabel("Welcome.");
		panelNorth.add(welcome);
		panelNorth.setPreferredSize(new Dimension(500, 50));
		add(panelNorth, BorderLayout.NORTH);
   
		//west-center panel
		JPanel panelLeft = new JPanel();
		Color myColor2 = new Color(250, 200, 50);
		panelLeft.setBackground(myColor2);
		panelLeft.setLayout(new BoxLayout(panelLeft, BoxLayout.Y_AXIS));
		panelLeft.setPreferredSize(new Dimension(300, 400));
  
		//subpanel in the west-center panel
		JPanel subLeft0 = new JPanel();
		subLeft0.setBackground(myColor2);
		subLeft0.setLayout(new GridLayout(3,1));
		JLabel appointment = new JLabel("  1.  Schedule an appointment.");
		JLabel text1 = new JLabel("  Please enter the date/time of your appointment:");
		subLeft0.add(appointment);
		subLeft0.add(text1);
		panelLeft.add(subLeft0);
   
		//another subpanel
		JPanel subLeft = new JPanel();
		subLeft.setBackground(myColor2);
		JLabel instruction = new JLabel("  Date: ");
		dateText = new JTextField(18);
		subLeft.add(instruction);
		subLeft.add(dateText);
		panelLeft.add(subLeft);
   
		//another subpanel
		JPanel subLeft2 = new JPanel();
		subLeft2.setBackground(myColor2);
		JLabel instruction2 = new JLabel("  Time: ");
		timeText = new JTextField(18);
		subLeft2.add(instruction2);
		subLeft2.add(timeText);
		panelLeft.add(subLeft2);
		
		//another subpanel
		JPanel subLeft3 = new JPanel(); 
		subLeft3.setBackground(myColor2);
		subLeft3.setLayout(new BoxLayout(subLeft3, BoxLayout.Y_AXIS));
		JButton requestAppointment = new JButton("Schedule");
		requestAppointment.addActionListener(new AppointmentListener());
		JButton checkmyAppointment = new JButton("Confirm Existing");
		subLeft3.add(Box.createHorizontalGlue());
		subLeft3.add(requestAppointment);
		subLeft3.add(Box.createRigidArea(new Dimension(0, 20)));
		subLeft3.add(checkmyAppointment);
		panelLeft.add(subLeft3);
   
		add(panelLeft, BorderLayout.WEST);
   
		//center-center panel
		JPanel panelCenter = new JPanel();
		panelCenter.setBackground(myColor2);
		panelCenter.setPreferredSize(new Dimension(200, 400));
		Border pb = BorderFactory.createLineBorder(Color.BLACK, 2);
		panelCenter.setBorder(pb);
		JLabel appointmentLabel = new JLabel("  2.  View Medical History.");
		JButton viewHistory = new JButton("View Medical History");
		panelCenter.add(appointmentLabel);
		panelCenter.add(viewHistory);
		add(panelCenter, BorderLayout.CENTER);
   
		//center-east panel
		JPanel panelEast = new JPanel();
		panelEast.setBackground(myColor2);
		panelEast.setPreferredSize(new Dimension(200, 400));
		JLabel filler = new JLabel("3.  Do something else");
		JButton fillerB = new JButton("Do that something else");
		panelEast.add(filler);
		panelEast.add(fillerB);
		add(panelEast, BorderLayout.EAST);
   
		//southern panel
		JPanel panelSouth = new JPanel();
		panelSouth.setBackground(myColor);
		panelSouth.setPreferredSize(new Dimension(500, 50));
		JButton help = new JButton("Help");
		JButton logOut = new JButton("Log Out");
		logOut.addActionListener(new LogoutListener());
		panelSouth.setLayout(new BoxLayout(panelSouth, BoxLayout.X_AXIS));
		panelSouth.add(Box.createHorizontalGlue());
		panelSouth.add(help);
		panelSouth.add(logOut);
		add(panelSouth, BorderLayout.SOUTH);
	}
 
	private class AppointmentListener implements ActionListener
	{
		public void actionPerformed(ActionEvent event)
		{
//			String time = timeText.getText();
//			String date = dateText.getText();
//			Appointment.makeAppointment(time, date, myUserID);
		}
	}
 
	private class LogoutListener implements ActionListener
	{
		public void actionPerformed(ActionEvent event)
		{
//			Index.indexFrame.dispose();
//			LoginScreen loginScreen = new LoginScreen();
//			loginScreen.show();
		}
	}
}